package utils;

import java.util.Map;

public class SparqlClientExample {

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        SparqlClient sparqlClient = new SparqlClient("localhost:3030/space");

        String query = "ASK WHERE { ?s ?p ?o }";
        boolean serverIsUp = sparqlClient.ask(query);
        if (serverIsUp) {
            System.out.println("server is UP");

            System.out.println("test requête");
            query = "PREFIX : <http://ontologies.alwaysdata.net/space#>\n"
                    + "PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"
                    + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"
                    + "PREFIX owl:  <http://www.w3.org/2002/07/owl#>\n"
                    + "PREFIX xsd:  <http://www.w3.org/2001/XMLSchema#>\n"
                    + "SELECT *\n"
                    + "WHERE {\n"
                    + "  ?x rdfs:label ?label.\n"
                    + "  ?x rdfs:label ?synonyme\n."
                    + "  FILTER regex(?label, \"balade\")\n"
                    + "}\n";
            
            Iterable<Map<String, String>> results = sparqlClient.select(query);
            System.out.println("Liste test");
            for (Map<String, String> result : results) {
                System.out.println(result.get("x") + " - " + result.get("label") + " - " + result.get("synonyme"));
            }
            
            
        } else {
            System.out.println("service is DOWN");
        }
    }
  
}
